import request from '@/utils/request';
import type {CartListResponseData, FoodResponseData, ShopInfo, ShopQuery, ShopUpdateData} from "@/api/shop/type.ts";

enum API{
    FOOD_LIST="/Food/listFoodByBusinessId/",
    //购物车相关操作
    SHOP_LIST="/Cart/listCart",
    SHOP_INSERT="/Cart/saveCart",
    SHOP_UPDATE="/Cart/updateCart",
    SHOP_DELETE="/Cart/removeCart"
}
//查询商家对应的食物
export const reqFoodInfo=(data: number | string)=>request.get<any,FoodResponseData>(API.FOOD_LIST+data);

//购物车查询
export const reqShopInfo=(data:ShopQuery)=>request.post<any,CartListResponseData>(API.SHOP_LIST,data)
//购物车新增
export const AddShop=(data:ShopInfo)=>request.post<any,any>(API.SHOP_INSERT, data);
//购物车修改
export const UpdateShop=(data:ShopUpdateData)=>request.put<any,any>(API.SHOP_UPDATE,data);
//购物车删除

export const RemoveShop = (data: ShopInfo) => {
    return request.delete<any, any>(API.SHOP_DELETE, {
        data: data, // 将 ShopInfo 对象作为请求体发送
        headers: {
            'Content-Type': 'application/json', // 确保发送正确的 Content-Type
        },
    });
};